//
//  main.cpp
//  Observer
//
//  Created by Shane on 17/9/18.
//  Copyright © 2017年 Shane. All rights reserved.
//

#include <iostream>
#include "ConcreteSubject.h"
#include "ConcreteObserver.h"
#include "ConcreteObserver2.h"

int main(int argc, const char * argv[]) {
    // insert code here...
    ConcreteSubject *pSubject = new ConcreteSubject();
    
    Observer *pObserver = new ConcreteObserver(pSubject);
    Observer *pObserver2 = new ConcreteObserver2(pSubject);
    
    pSubject->attach(pObserver);
    pSubject->attach(pObserver2);
    
    pSubject->setState(1024);
    pSubject->notify();
    
    pSubject->detach(pObserver);
    pSubject->setState(2048);
    pSubject->notify();
    
    delete pSubject;
    delete pObserver;
    delete pObserver2;
    
    return 0;
}
